# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=open-lldp
pkgver=1.1
pkgrel=1
pkgdesc="Open Source implementation of the IEEE standard 802.1AB Link Layer Discovery Protocol (LLDP)"
url="http://www.open-lldp.org"
arch="all"
license="GPL-2.0-only"
makedepends="
	autoconf
	automake
	bsd-compat-headers
	flex
	libconfig-dev
	libnl3-dev
	libtool
	linux-headers
	readline-dev
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-openrc
	$pkgname-bash-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/intel/openlldp/archive/refs/tags/v$pkgver.tar.gz
	reopenstdout.patch
	lldpad.initd
	lldpad.confd
	"
	# clif.h.patch
builddir="$srcdir/openlldp-$pkgver"

prepare() {
	default_prepare
	# sed -i 's/ln -T -s/ln -s/' Makefile.am
	# sed -i -e 's/-Werror//' Makefile.am configure.ac
	./bootstrap.sh
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	rm -r "$pkgdir"/usr/lib/systemd

	install -Dm755 "$srcdir"/lldpad.initd "$pkgdir"/etc/init.d/lldpad
	install -Dm644 "$srcdir"/lldpad.confd "$pkgdir"/etc/conf.d/lldpad

	mkdir -p "$pkgdir"/usr/share/bash-completion
	mv "$pkgdir"/etc/bash_completion.d "$pkgdir"/usr/share/bash-completion/completions
}

sha512sums="
794bd2d43e7b6e76a1aa9d1e650f24a52b4cb66166058ce4ec3f0c6567bcdff149ca86ab9108e82be14f7e7bf43c7486479edc23d851e739a2a22de7038ecb35  open-lldp-1.1.tar.gz
74cf3d7ef3c6d00cf05713bf5ef505292b6cfd7d6e080993947e88a44d725906d7243d59ee12bb468c093dc26937a5efe8fb644eca1d4c5b545825ce78253362  reopenstdout.patch
d8c7d3c449a9c557814f70a5af15b1b8e34f4c465293aa962bc3a8310e24f8363cf15e75d3cbdc8894ca7a0b1e1962daaaba75ecb0caf770471ae0988e85be7b  lldpad.initd
5dc09090913e55bde9aab3ad33eb7889942bb7a0583ae1a94cc31f6c8e34ccae18c02f2c191e157f81f2949cc91998d673b37d60522dc9c476d63136512f2b58  lldpad.confd
"
